package com.qc.ayouth.shop.admin.beans;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qc.ayouth.shop.core.beans.vo.ResponseVO;

/**
 * 接口返回数据格式
 */
public class AdminResponseVO extends ResponseVO {

	/**
	 * @description: 根据前端需求设定的字段Key
	 * @author: haojg
	 * @date: 2020/7/8 11:10
	 * @param pageInfo
	 * @return: com.qc.ayouth.shop.core.beans.vo.ResponseVO
	 */
	public ResponseVO addList(IPage pageInfo){
		// 记录数据：对应table的赋值
		this.getData().put("data", pageInfo.getRecords());
		// 总记录数
		this.getData().put("totalCount", pageInfo.getTotal());
		// 总页数
		this.getData().put("totalPage", pageInfo.getPages());
		// 当前第几页
		this.getData().put("pageNo", pageInfo.getCurrent());
		// 每页显示的记录数
		this.getData().put("pageSize", pageInfo.getSize());

		//是否还有下一页
		if (pageInfo.getRecords().size() < pageInfo.getSize()) {
			this.getData().put("hasNext", false);
		} else {
			this.getData().put("hasNext", true);
		}
		return this;
	}

}
